/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.raytracer;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;

/**
 *
 * @author drafkind
 */
public class ViewPort extends JPanel {
  private Image image;

  public ViewPort() {
    image = null;
    this.setOpaque(true);
    this.setDoubleBuffered(true);
  }

  public void setImage(Image image) {
    this.image = image;
    this.repaint();
  }

  @Override
  protected void paintComponent(Graphics g) {
    if (image != null) {
      g.drawImage(image,
              0, 0, this.getWidth(), this.getHeight(),
              0, 0, image.getWidth(this), image.getHeight(this),
              Color.MAGENTA, this);
    }
  }
}